﻿<UserControl x:Class="Atlanchim.Crm.Mui.Pages.Alertes.PageEditAlerte"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="20"/>
            <RowDefinition Height="20"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--Entête-->
        <TextBlock Text="Alerte" Style="{StaticResource Heading2}" />

        <!--Actions-->
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
            <mui:ModernButton Content="Enregistrer"
                          Command="{Binding Path=SaveCommand}" CommandParameter="{Binding}"
                          IconData="{DynamicResource LmondeilSaveButtonPath}" Foreground="{DynamicResource LmondeilSaveButtonColor}" />
            <mui:ModernButton Content="Annuler"
                              Margin="10,0,0,0"
                          Command="{Binding Path=CancelCommand}" CommandParameter="{Binding}"
                          IconData="{DynamicResource LmondeilCancelButtonPath}" Foreground="{DynamicResource LmondeilCancelButtonColor}" />
        </StackPanel>


        <!--informations sur l'email-->
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="40"/>
                <RowDefinition Height="30"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Rectangle Fill="{DynamicResource ResourceKey=AlerteColor}" Grid.RowSpan="3"/>

            <TextBlock Text="Date" Grid.Row="0" Grid.Column="0"
                     VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Style="{DynamicResource MandatoryTextBlock}" />
            <DatePicker Text="{Binding Path=Alerte.Date, Mode=TwoWay}" Grid.Row="0" Grid.Column="2" SelectedDateFormat="Short" 
                     VerticalAlignment="Top" Margin="0,10,0,0" />

            <TextBlock Text="Titre" Grid.Row="1" Grid.Column="0"
                     VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,3,10,0" />
            <TextBox Text="{Binding Path=Alerte.Titre, FallbackValue='[Titre]'}" Grid.Row="1" Grid.Column="2" Margin="0,3,0,3"/>

            <TextBlock Text="Contact" Grid.Row="2" Grid.Column="0"
                     VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,3,10,0" Style="{DynamicResource MandatoryTextBlock}" />
            
            <TextBlock Text="{Binding Path=ContactFullName, FallbackValue='[ContactFullName]'}" 
                       Grid.Row="2" Grid.Column="2" Margin="0,3,0,0"/>
        </Grid>

        <ScrollViewer Grid.Row="3">
            <StackPanel>

                <!--Entête-->
                <TextBlock Text="Sélection du contact" Style="{StaticResource Heading2}" />

                <!--Liste des contacts-->
                <DataGrid ItemsSource="{Binding ContactsList}" AutoGenerateColumns="False" HorizontalAlignment="Left"
                      CanUserResizeColumns="True" CanUserSortColumns="True" SelectionMode="Extended" ColumnHeaderStyle="{DynamicResource headerStyle}" >
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="Prénom" IsReadOnly="True" SortMemberPath="Prenom" Width="Auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding Prenom}"
                                    Command="ApplicationCommands.Replace" CommandParameter="{Binding}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="Nom" IsReadOnly="True" SortMemberPath="Nom" Width="Auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding Nom}"
                                    Command="ApplicationCommands.Replace" CommandParameter="{Binding}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="Société" IsReadOnly="True" SortMemberPath="Societe.Nom" Width="*">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding Societe.Nom}"
                                    Command="ApplicationCommands.Replace" CommandParameter="{Binding}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>
            </StackPanel>
        </ScrollViewer>

    </Grid>
</UserControl>
